﻿using System.Globalization;

namespace Isuka.Text
{

    public static class CharExtensions
    {

        public static bool IsCJKUnifiedIdeographs(this char ch)
        {
            return 0x4E00 <= ch && ch <= 0x9FFF;
        }

        public static bool IsCJKUnifiedIdeographsExA(this char ch)
        {
            return 0x3400 <= ch && ch <= 0x4DFF;
        }

        public static bool IsHiragana(this char ch)
        {
            return 0x3040 <= ch && ch <= 0x309F;
        }

        public static bool IsKatanaka(this char ch)
        {
            return 0x30A0 <= ch && ch <= 0x30FF;
        }

        public static bool IsLineSeparator(this char ch)
        {
            return char.GetUnicodeCategory(ch) == UnicodeCategory.LineSeparator;
        }

        public static bool IsRfc3986Unreserved(this char ch)
        {
            return ('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') || ('0' <= ch && ch <= '9') || ("-_.~".IndexOf(ch) >= 0);
        }
    }
}
